I am having trouble with getting specific information from my xml using stax. Inside my xml I have a current and average which both have a traveltime inside them. But I only want to get the traveltime from the current and not from the average. Here is how my xml looks like:
<allroutes>
<routes>
<route identification="id_1">
<current>
<traveltime time="1187" trustworthy="j" />
<delay time="0" trustworthy="j" />
</current>
<average>
<traveltime time="1187" trustworthy="j" />
<delay time="0" trustworthy="j" />
</average>
</route>
<route identification="id_2">
<current>
<traveltime time="995" trustworthy="j" />
<delay time="0" trustworthy="j" />
</current>
<average>
<traveltime time="995" trustworthy="j" />
<delay time="0" trustworthy="j" />
</average>
</route>
</routes>
<subpaths>
<subpath identification="id_1">
<current>
<traveltime time="0" trustworthy="n" />
<delay time="0" trustworthy="n" />
</current>
<average>
<traveltime time="0" trustworthy="n" />
<delay time="0" trustworthy="n" />
</average>
</subpath>
<subpath identification="id_2">
<current>
<traveltime time="0" trustworthy="n" />
<delay time="0" trustworthy="n" />
</current>
<average>
<traveltime time="0" trustworthy="n" />
<delay time="0" trustworthy="n" />
</average>
</subpath>
</subpaths>
</allroutes>
The code that I have currently looks like this:
try{
while (streamReader.hasNext()) {
streamReader.next();
if (streamReader.getEventType() == XMLStreamReader.START_ELEMENT) {
switch (streamReader.getLocalName()) {
case "route":
//store which type
break;
case "subpath":
//store which type
break;
case "traveltime":
//store traveltime
break;
}
}
if (streamReader.getEventType() == XMLStreamReader.END_ELEMENT && "allroutes".equals(streamReader.getLocalName())) {
//stop the loop and give back the object
}
}
}catch(XMLStreamException ex) {
LOGGER.log(Level.SEVERE, "XMLStreamException: " + ex);
}
What do I need to add / change to only get the traveltime from 'current' inside this reader?
You just have to keep track of where you are in the document. For example, it's common practice to keep a stack of element names: push a name onto the stack when you hit a startElement, pop it off when you hit endElement, and then inspect the stack to discover the context of the element you are currently processing.
Related
I had recently installed java adopt JDK 1.8.0_202 version.
It worked fine for the first time and later when i start hybris server getting the below issue again & again on console :
JVMJ9GC063E Unable to open file '/opt/hybris/log/tomcat/java_gc_ger-d-maa-apsp-001.log' for writing
<allocation-stats totalBytes="223210880" >
<allocated-bytes non-tlh="13688" tlh="223197192" />
<largest-consumer threadName="localhost-startStop-1" threadId="0000000002F7B000" bytes="217285784" />
</allocation-stats>
<gc-op id="2563" type="scavenge" timems="53.990" contextid="2560" timestamp="2019-03-14T15:18:57.791">
<scavenger-info tenureage="14" tenuremask="4000" tiltratio="88" />
<memory-copied type="nursery" objects="394430" bytes="16048744" bytesdiscarded="115760" />
<finalization candidates="204" enqueued="174" />
<ownableSynchronizers candidates="3195" cleared="7" />
<references type="soft" candidates="9645" cleared="0" enqueued="0" dynamicThreshold="32" maxThreshold="32" />
<references type="weak" candidates="6673" cleared="84" enqueued="67" />
</gc-op>
<gc-end id="2564" type="scavenge" contextid="2560" durationms="54.398" usertimems="46.801" systemtimems="0.000" timestamp="2019-03-14T15:18:57.791" activeThreads="2">
<mem-info id="2565" free="564246568" total="1073741824" percent="52">
<mem type="nursery" free="224266520" total="268435456" percent="83">
<mem type="allocate" free="224266520" total="240451584" percent="93" />
<mem type="survivor" free="0" total="27983872" percent="0" />
</mem>
<mem type="tenure" free="339980048" total="805306368" percent="42" macro-fragmented="3110739">
<mem type="soa" free="299715344" total="765041664" percent="39" />
<mem type="loa" free="40264704" total="40264704" percent="100" />
</mem>
<pending-finalizers system="174" default="0" reference="67" classloader="0" />
<remembered-set count="33247" />
</mem-info>
</gc-end>
<cycle-end id="2566" type="scavenge" contextid="2560" timestamp="2019-03-14T15:18:57.792" />
<allocation-satisfied id="2567" threadId="0000000002F7B000" bytesRequested="48" />
<af-end id="2568" timestamp="2019-03-14T15:18:57.792" threadId="0000000002F7B988" success="true" from="nursery"/>
<exclusive-end id="2569" timestamp="2019-03-14T15:18:57.792" durationms="55.438" />
<exclusive-start id="2570" timestamp="2019-03-14T15:19:06.478" intervalms="8740.918">
<response-info timems="0.039" idlems="0.039" threads="0" lastid="0000000002F7B000" lastname="localhost-startStop-1" />
</exclusive-start>
<af-start id="2571" threadId="0000000002F7B988" totalBytesRequested="24" timestamp="2019-03-14T15:19:06.478" intervalms="8740.939" type="nursery" />
<cycle-start id="2572" type="scavenge" contextid="0" timestamp="2019-03-14T15:19:06.478" intervalms="8740.941" />
<gc-start id="2573" type="scavenge" contextid="2572" timestamp="2019-03-14T15:19:06.479">
<mem-info id="2574" free="339975744" total="1073741824" percent="31">
<mem type="nursery" free="0" total="268435456" percent="0">
<mem type="allocate" free="0" total="240451584" percent="0" />
<mem type="survivor" free="0" total="27983872" percent="0" />
</mem>
<mem type="tenure" free="339975744" total="805306368" percent="42">
<mem type="soa" free="299711040" total="765041664" percent="39" />
<mem type="loa" free="40264704" total="40264704" percent="100" />
</mem>
<remembered-set count="34712" />
</mem-info>
</gc-start>
Any help would be appreciated?
Thanks,
Mohammed
This logs produced by -verbose:gc (or similar) JVM option.
You should remove that option if you don't need this logs.
We're going to build a workflow management system and We're embedding the camunda engine Rest API into our Rest Application.
Now I have Inventory defined like this:
public class Inventory {
private String objectName;
private int objectCount;
// getters and setters
}
and this is a sample workflow:
in xml:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:process id="test" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1v6clcy</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1v6clcy" sourceRef="StartEvent_1" targetRef="testtask" />
<bpmn:userTask id="testtask" name="testtask" camunda:formKey="testform">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="inventories" label="name" type="List<org.example.Inventory>" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1v6clcy</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_07kdfp4</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_0vm605w">
<bpmn:incoming>SequenceFlow_07kdfp4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_07kdfp4" sourceRef="testtask" targetRef="EndEvent_0vm605w" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1v6clcy_di" bpmnElement="SequenceFlow_1v6clcy">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="275" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="242" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1s01hea_di" bpmnElement="testtask">
<dc:Bounds x="275" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0vm605w_di" bpmnElement="EndEvent_0vm605w">
<dc:Bounds x="439" y="109" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="412" y="149" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_07kdfp4_di" bpmnElement="SequenceFlow_07kdfp4">
<di:waypoint xsi:type="dc:Point" x="375" y="120" />
<di:waypoint xsi:type="dc:Point" x="407" y="120" />
<di:waypoint xsi:type="dc:Point" x="407" y="127" />
<di:waypoint xsi:type="dc:Point" x="439" y="127" />
<bpmndi:BPMNLabel>
<dc:Bounds x="377" y="117.5" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
I'll eventually have a html form which will submit something like this:
{
"inventories" : [{"name": "banana","count": 3},{"name":"orange","count": 4}]
}
I want to submit this to /task/{id}/submit-form but I don't know what to put as type.
I tried putting the type in modeler as List<org.example.Inventory> but the rest api throws an exception when deploying the process definition like this:
org.camunda.bpm.engine.ProcessEngineException: ENGINE-09005 Could not parse BPMN process. Errors:
* unknown type 'List' | org.example/PM.bpmn | line 65 | column 90
I've seen this example as well but I'm only using the Rest API not the whole bpm platform(besides we prefer to have pure html forms).
So how to do it ? what should I put in type ?
my camunda.cfg.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
my processengineprovider:
public class MyProcessEngineProvider implements ProcessEngineProvider {
#Override
public ProcessEngine getDefaultProcessEngine() {
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = engine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org.newtech/PM.bpmn")
.deploy();
return engine;
}
#Override
public ProcessEngine getProcessEngine(String s) {
return getDefaultProcessEngine();
}
#Override
public Set<String> getProcessEngineNames() {
Set<String> names = new HashSet<>(1);
names.add("default");
return names;
}
}
Process Compilation error : org.drools.lang.descr.ProcessDescr#4c60d6e9
com/sample/Process_com_sample_ruleflowsample.java (21:862) : Type mismatch: cannot convert from int to String
com/sample/Process_com_sample_ruleflowsample.java (29:1151) : Type mismatch: cannot convert from int to String
This is my ruleflowsample.rf under src/main/rules that is throwing the above error.
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="ruleflowsample" id="com.sample.ruleflowsample" package-name="com.sample" >
<header>
<imports>
<import name="com.sample.Employee" />
</imports>
<variables>
<variable name="caffeineIntake" >
<type name="org.drools.process.core.datatype.impl.type.FloatDataType" />
</variable>
</variables>
</header>
<nodes>
<start id="1" name="Start" x="12" y="129" width="48" height="48" />
<split id="2" name="Gateway" x="101" y="128" width="49" height="49" type="2" >
<constraints>
<constraint toNodeId="4" toType="DROOLS_DEFAULT" name="Coffee" priority="1" type="code" dialect="java" >return caffeineIntake>0.105F;</constraint>
<constraint toNodeId="5" toType="DROOLS_DEFAULT" name="Tea" priority="1" type="code" dialect="java" >return caffeineIntake>0.04F;</constraint>
</constraints>
</split>
<actionNode id="4" name="Coffee" x="198" y="205" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of coffee cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<actionNode id="5" name="Tea" x="196" y="61" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of tea cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<end id="6" name="End" x="386" y="127" width="48" height="48" />
<join id="7" name="Gateway" x="311" y="127" width="49" height="49" type="2" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="4" />
<connection from="2" to="5" />
<connection from="7" to="6" />
<connection from="5" to="7" />
<connection from="4" to="7" />
</connections>
</process>
I know the error is occurring because of this line: System.out.println("caffeineIntake");
I want to access this input variable i.e. caffeineIntake to perform some operation on it.
The error is not occurring because of this line: System.out.println("caffeineIntake");
It is occurring because of the Dialect option selection:
Using this option as mvel rather than java resolved the issue.
Well,
from my point of view
String noOfCups = 1;
is the problem.
perhaps change it to
String noOfCups = "1";
I have implemented Spring Security in my restful web service. In fact, I have to add an extra parameter with the request from client side and should fetch it from the service when request for authentication/accesstoken.
spring-security.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd ">
<!-- #author Nagesh.Chauhan(neel4soft#gmail.com) -->
<!-- This is default url to get a token from OAuth -->
<http pattern="/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<anonymous enabled="false" />
<http-basic entry-point-ref="clientAuthenticationEntryPoint" />
<!-- include this only if you need to authenticate clients via request
parameters -->
<custom-filter ref="clientCredentialsTokenEndpointFilter"
after="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<!-- This is where we tells spring security what URL should be protected
and what roles have access to them -->
<http pattern="/api/**" create-session="never"
entry-point-ref="oauthAuthenticationEntryPoint"
access-decision-manager-ref="accessDecisionManager"
xmlns="http://www.springframework.org/schema/security">
<anonymous enabled="false" />
<intercept-url pattern="/api/**" access="ROLE_APP" />
<custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<bean id="oauthAuthenticationEntryPoint"
class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
<property name="realmName" value="test" />
</bean>
<bean id="clientAuthenticationEntryPoint"
class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
<property name="realmName" value="test/client" />
<property name="typeName" value="Basic" />
</bean>
<bean id="oauthAccessDeniedHandler"
class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />
<bean id="clientCredentialsTokenEndpointFilter"
class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
<property name="authenticationManager" ref="clientAuthenticationManager" />
</bean>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"
xmlns="http://www.springframework.org/schema/beans">
<constructor-arg>
<list>
<bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" />
<bean class="org.springframework.security.access.vote.RoleVoter" />
<bean class="org.springframework.security.access.vote.AuthenticatedVoter" />
</list>
</constructor-arg>
</bean>
<authentication-manager id="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<authentication-provider user-service-ref="clientDetailsUserService" />
</authentication-manager>
<!-- Custom User details service which is provide the user data -->
<bean id="customUserDetailsService"
class="com.weekenter.www.service.impl.CustomUserDetailsService" />
<authentication-manager alias="authenticationManager"
xmlns="http://www.springframework.org/schema/security">
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder hash="plaintext">
</password-encoder>
</authentication-provider>
</authentication-manager>
<bean id="clientDetailsUserService"
class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService">
<constructor-arg ref="clientDetails" />
</bean>
<!-- This defined token store, we have used inmemory tokenstore for now
but this can be changed to a user defined one -->
<bean id="tokenStore"
class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore" />
<!-- This is where we defined token based configurations, token validity
and other things -->
<bean id="tokenServices"
class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
<property name="tokenStore" ref="tokenStore" />
<property name="supportRefreshToken" value="true" />
<property name="accessTokenValiditySeconds" value="120" />
<property name="clientDetailsService" ref="clientDetails" />
</bean>
<bean id="userApprovalHandler"
class="org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler">
<property name="tokenServices" ref="tokenServices" />
</bean>
<oauth:authorization-server
client-details-service-ref="clientDetails" token-services-ref="tokenServices"
user-approval-handler-ref="userApprovalHandler">
<oauth:authorization-code />
<oauth:implicit />
<oauth:refresh-token />
<oauth:client-credentials />
<oauth:password />
</oauth:authorization-server>
<oauth:resource-server id="resourceServerFilter"
resource-id="test" token-services-ref="tokenServices" />
<oauth:client-details-service id="clientDetails">
<!-- client -->
<oauth:client client-id="restapp"
authorized-grant-types="authorization_code,client_credentials"
authorities="ROLE_APP" scope="read,write,trust" secret="secret" />
<oauth:client client-id="restapp"
authorized-grant-types="password,authorization_code,refresh_token,implicit"
secret="restapp" authorities="ROLE_APP" />
</oauth:client-details-service>
<sec:global-method-security
pre-post-annotations="enabled" proxy-target-class="true">
<!--you could also wire in the expression handler up at the layer of the
http filters. See https://jira.springsource.org/browse/SEC-1452 -->
<sec:expression-handler ref="oauthExpressionHandler" />
</sec:global-method-security>
<oauth:expression-handler id="oauthExpressionHandler" />
<oauth:web-expression-handler id="oauthWebExpressionHandler" />
</beans>
CustomUserDetailsService
#Service
#Transactional(readOnly = true)
public class CustomUserDetailsService implements UserDetailsService {
#Autowired
private LoginDao loginDao;
public UserDetails loadUserByUsername(String login)
throws UsernameNotFoundException {
boolean enabled = true;
boolean accountNonExpired = true;
boolean credentialsNonExpired = true;
boolean accountNonLocked = true;
com.weekenter.www.entity.User user = null;
try {
user = loginDao.getUser(login);
if (user != null) {
if (user.getStatus().equals("1")) {
enabled = false;
}
} else {
throw new UsernameNotFoundException(login + " Not found !");
}
} catch (Exception ex) {
try {
throw new Exception(ex.getMessage());
} catch (Exception ex1) {
}
}
return new User(
user.getEmail(),
user.getPassword(),
enabled,
accountNonExpired,
credentialsNonExpired,
accountNonLocked,
getAuthorities()
);
}
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authList = getGrantedAuthorities(getRoles());
return authList;
}
public List<String> getRoles() {
List<String> roles = new ArrayList<String>();
roles.add("ROLE_APP");
return roles;
}
public static List<GrantedAuthority> getGrantedAuthorities(List<String> roles) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
for (String role : roles) {
authorities.add(new SimpleGrantedAuthority(role));
}
return authorities;
}
}
Currently I am requesting with the URL:
http://localhost:8084/Domain/oauth/token?grant_type=password&client_id=restapp&client_secret=restapp&username=anoo#codelynks.com&password=mypass
And I will get the response
{
"access_token":"76e928b2-45e2-4283-88a4-6c01f41b51d3","token_type":"bearer","refresh_token":"8748e8ad-79c1-465d-94fe-13394eea370d","expires_in":119
}
I have to enhance it by adding additional parameter deviceToken.
And the URL would be:
http://localhost:8084/Domain/oauth/token?grant_type=password&client_id=restapp&client_secret=restapp&username=anoo#codelynks.com&password=mypass&deviceToken=something
I have treid by implementing UsernamePasswordAuthenticationFilter, but it didn't work. How can I get the deviceToken parameter from the web service without affecting the output?
http://localhost:8084/Domain/oauth/token?grant_type=password&client_id=restapp&client_secret=restapp&username=anoo#codelynks.com&password=mypass&additional_param=abc123
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
log.info("additional_param: " + request.getParameter("additional_param"));
log will show
additional_param: abc123
Although AOP is used when it comes to crosscutting concerns, this approach worked as expected and I think It is a valid approach.
#Aspect
public class Oauth2Aspect {
#AfterReturning("execution( * org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(..))")
public void executeAfterAuthentication() throws Exception {
System.out.println(":Authentication done");
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
System.out.println(":Authentication done " + request.getParameter("deviceInfo"));
}
}
In my Flex Application MXML file i'm writing..
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="598" height="459" creationComplete="consumer.subscribe()" layout="vertical">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.messaging.messages.AsyncMessage;
import mx.messaging.messages.IMessage;
public function send():void {
var message:IMessage = new AsyncMessage();
message.destination = "SimpleChatDestination";
message.body = "\n" + usernameInput.text + ":\t" + messageInput.text;
trace(producer.connected);
producer.send(message);
messageInput.text = "";
}
public function messageHandler( message:IMessage ):void {
textArea.text += message.body;
}
]]>
</mx:Script>
<mx:Producer id="producer" destination="SimpleChatDestination"/>
<mx:Consumer id="consumer" destination="SimpleChatDestination" message="messageHandler(event.message)"/>
<mx:TextArea id="textArea" width="400" height="300" color="#F31C1C" editable="false"
enabled="false"/>
<mx:HBox horizontalGap="0">
<mx:TextInput id="usernameInput" width="80"/>
<mx:TextInput id="messageInput" width="180"/>
<mx:Button label="Send" click="send();"/>
</mx:HBox>
</mx:Application>
And in BlazeDs(java side) message-config.xml file i wrote code like this.
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<!-- <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<adapters>
<adapter-definition id="actionscript" default="true" />
<!-- <adapter-definition id="jms"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<destination id="SimpleChatDestination">
<properties>
<network>
<subscription-timeout-minutes>0</subscription-timeout-minutes>
</network>
<server>
<message-time-to-live>0</message-time-to-live>
<allow-subtopics>true</allow-subtopics>
<subtopic-separator>.</subtopic-separator>
</server>
</properties>
</destination>
</service>
So it is Working fine. But problem is when ever we open three are four chat boxes then all chat boxes are participated.
i want only allow two user can only chat if 3rd user came not visiable 2nd person chating information.
just it is like Facebook,Gmail chating.
plz help me..