Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] AspectJ syntax errors in AJHotDraw -v0.4

Hi !! All

AspectJ syntax errors in AJHotDraw -v0.4 in  /**JDOStorageFormat.java**/ class 22 errors type mismatch and can't resolve toa type.
Please somebody can help me on Ubuntu 10.10  and same problem on Win XP/Win 7 in Eclipse . All highlighted lines are errors.

/**JDOStorageFormat.java**/

package org.jhotdraw.util;

import org.jhotdraw.framework.*;

import org.jhotdraw.standard.StandardDrawing;

import java.io.*;

import java.util.*;

import java.util.List;

import java.awt.*;

import javax.jdo.*;

import javax.swing.*;

import javax.swing.event.ListSelectionListener;

import javax.swing.event.ListSelectionEvent;






public String store(String fileName, Drawing storeDrawing) throws IOException {

PersistenceManager pm = getPersistenceManager(fileName);

String drawingName = null;

Drawing txnDrawing = crossTxnBoundaries(storeDrawing);

endTransaction(pm, false);

startTransaction(pm);

try {

Extent extent = pm.getExtent(StandardDrawing.class, true);

DrawingListModel listModel = new DrawingListModel(extent.iterator());

drawingName = showStoreDialog(listModel, storeDrawing);

if (drawingName != null) {

storeDrawing.setTitle(drawingName);

txnDrawing.setTitle(drawingName);

pm.makePersistent(txnDrawing);

}

}

finally {

endTransaction(pm, (drawingName != null));

}

// there must be always a transaction running

startTransaction(pm);

return drawingName;

}

/**

* Restore a Drawing from a file with a given name. The name must be should with regard to the

* FileFilter that means, it should have the appropriate file extension.

*

* @param fileName of the file in which the Drawing has been saved

* @return restored Drawing

*/

public synchronized Drawing restore(String fileName) throws IOException {

PersistenceManager pm = getPersistenceManager(fileName);

endTransaction(pm, false);

startTransaction(pm);

Drawing restoredDrawing = null;

try {

Extent extent = pm.getExtent(StandardDrawing.class, true);

DrawingListModel listModel = new DrawingListModel(extent.iterator());

Drawing txnDrawing = showRestoreDialog(listModel);

if (txnDrawing != null) {

// pm.retrieve(txnDrawing);

// retrieveAll(pm, (StandardDrawing)txnDrawing);

// restoredDrawing = crossTxnBoundaries(txnDrawing);

restoredDrawing = txnDrawing;

}

}

finally {

endTransaction(pm, false);

}

// there must be always a transaction running

startTransaction(pm);

return restoredDrawing;

}

private void retrieveAll(PersistenceManager pm, Figure figure) {

pm.retrieve(figure);

FigureEnumeration fe = figure.figures();

while (fe.hasNextFigure()) {

retrieveAll(pm, fe.nextFigure());

}

}

private Drawing crossTxnBoundaries(Drawing originalDrawing) {

return (Drawing)((StandardDrawing)originalDrawing).clone();

// return originalDrawing;

}

private synchronized PersistenceManager getPersistenceManager(String fileName) {

PersistenceManager pm = (PersistenceManager)pms.get(fileName);

if (pm == null) {

pm = createPersistenceManagerFactory(fileName).getPersistenceManager();

pms.put(fileName, pm);

}

return pm;

}

private PersistenceManagerFactory createPersistenceManagerFactory(String dbFileName) {

Properties pmfProps = new Properties();

pmfProps.put(

"javax.jdo.PersistenceManagerFactoryClass",

"com.poet.jdo.PersistenceManagerFactories" );

pmfProps.put(

"javax.jdo.option.ConnectionURL",

"fastobjects://LOCAL/MyBase.j1" );

final PersistenceManagerFactory pmf =

JDOHelper.getPersistenceManagerFactory( pmfProps );

return pmf;

}

private static void startTransaction(PersistenceManager pm) {

if (!pm.currentTransaction().isActive()) {

pm.currentTransaction().begin();

}

}

private static void endTransaction(PersistenceManager pm, boolean doCommit) {

if (pm.currentTransaction().isActive()) {

if (doCommit) {

pm.currentTransaction().commit();

}

else {

pm.currentTransaction().rollback();

}

}

}

private String showStoreDialog(ListModel listModel, Drawing storeDrawing) {

final String msgString = "Specify a name for the drawing";

final JTextField nameTextField = new JTextField(storeDrawing.getTitle());

final JList dataList = new JList(listModel);

final JScrollPane dbContentScrollPane = new JScrollPane(dataList);

Object[] guiComponents = {msgString, dbContentScrollPane, nameTextField};

dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

dataList.setValueIsAdjusting(true);

dataList.addListSelectionListener(new ListSelectionListener() {

public void valueChanged(ListSelectionEvent e) {

nameTextField.setText(dataList.getSelectedValue().toString());

}

});

final JOptionPane optionPane = new JOptionPane(

guiComponents,

JOptionPane.PLAIN_MESSAGE,

JOptionPane.OK_CANCEL_OPTION);

final JDialog dialog = optionPane.createDialog(null, "Restore a drawing from the database");

// dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

// dialog.addWindowListener(new WindowAdapter() {

// public void windowClosing(WindowEvent we) {

// System.exit(0);

// }

// });

dialog.setVisible(true);

if ((optionPane.getValue() != null) && (optionPane.getValue().equals(new Integer(JOptionPane.OK_OPTION)))) {

return nameTextField.getText();

}

else {

return null;

}

}

private Drawing showRestoreDialog(DrawingListModel listModel) {

final String msgString = "Select a drawing";

final JList dataList = new JList(listModel);

final JScrollPane dbContentScrollPane = new JScrollPane(dataList);

Object[] guiComponents = {msgString, dbContentScrollPane};

dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

dataList.setValueIsAdjusting(true);

final JOptionPane optionPane = new JOptionPane(

guiComponents,

JOptionPane.PLAIN_MESSAGE,

JOptionPane.OK_CANCEL_OPTION);

final JDialog dialog = optionPane.createDialog(null, "Restore a drawing from the database");

dialog.setVisible(true);

if ((optionPane.getValue() != null)

&& (optionPane.getValue().equals(new Integer(JOptionPane.OK_OPTION)))

&& (dataList.getSelectedIndex() >= 0)

&& (dataList.getSelectedIndex() < dataList.getModel().getSize())) {

return listModel.getDrawingAt(dataList.getSelectedIndex());

}

else {

return null;

}

}

static class DrawingListModel extends AbstractListModel {

private List myList;

DrawingListModel(Iterator iter) {

myList = CollectionsFactory.current().createList();

while (iter.hasNext()) {

Object o = iter.next();

System.out.println("extent: " + o + " .. " + ((Drawing)o).getTitle());

myList.add(o);

}

}

public Object getElementAt(int index) {

return getDrawingAt(index).getTitle();

}

protected Drawing getDrawingAt(int index) {

return ((Drawing)myList.get(index));

}

public int getSize() {

return myList.size();

}

}

static class DrawingSelector extends JDialog {

DrawingSelector() {

init();

}

private void init() {

setTitle("Select Drawing");

getContentPane().setLayout(new BorderLayout());

getContentPane().add(new JLabel("Database content"), BorderLayout.NORTH);

setSize(200, 200);

}

}

public static void main(String[] args) {

DrawingSelector frame = new DrawingSelector();

try {

Drawing newDrawing = new StandardDrawing();

newDrawing.setTitle("TestDrawingName" + new Random(System.currentTimeMillis()).nextLong());

new JDOStorageFormat().store("base.j2", newDrawing);

System.exit(0);

}

catch (IOException e) {

e.printStackTrace();

}

// frame.setVisible(true);

}

}

  Thanking You,


Regards

S Kotrappa






On Wed, Dec 7, 2011 at 10:30 PM, <aspectj-users-request@xxxxxxxxxxx> wrote:
Send aspectj-users mailing list submissions to
       aspectj-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
       https://dev.eclipse.org/mailman/listinfo/aspectj-users
or, via email, send a message with subject or body 'help' to
       aspectj-users-request@xxxxxxxxxxx

You can reach the person managing the list at
       aspectj-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of aspectj-users digest..."


Today's Topics:

  1. How to inject a static field into a multitude of  types with
     AspectJ? (mark Kharitonov)
  2. AOSD 2012 Student Volunteer program (Eric Bodden)
  3. Re: How to inject a static field into a multitude of types
     with AspectJ? (Andy Clement)
  4. Re: Using aspect to pass a metadata as a parameter through
     SOAP (Andy Clement)


----------------------------------------------------------------------

Message: 1
Date: Wed, 7 Dec 2011 11:44:14 +0200
From: mark Kharitonov <mark.kharitonov@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] How to inject a static field into a multitude
       of      types with AspectJ?
Message-ID:
       <CAG2YSPyhWBuTPy83pW+bBJqkUhGZPmNM6vyyDLUPoEed+NBGyw@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="iso-8859-1"

I would like to add a log4j.Logger private static field into a multitude of
types. For instance, into all the types annotated with the @Path annotation.

This my current aspect code:

   public aspect LoggingAspect {
     public interface HttpHandlerType {}
     declare parents: (@Path *) implements HttpHandlerType;

     public Logger HttpHandlerType.Log = Logger.getLogger(getClass());

     pointcut httpHandlerMethods(HttpHandlerType o) :
within(HttpHandlerType+) &&
       execution(@(GET || PUT || POST || DELETE) public * *.*(..)) &&
this(o);

     before(HttpHandlerType o): httpHandlerMethods(o) {
       if (o.Log.isInfoEnabled()) {
         o.Log.info(logMethod(thisJoinPoint));
       }
     }

     after(HttpHandlerType o) returning (Object result):
httpHandlerMethods(o) {
       if (o.Log.isDebugEnabled()) {
         o.Log.debug(logMethod(thisJoinPoint, result));
       }
     }

     after(HttpHandlerType o) throwing (Exception e):
httpHandlerMethods(o) {
       if (o.Log.isEnabledFor(Level.ERROR)) {
         o.Log.error(logMethod(thisJoinPoint), e);
       }
     }

     private static String logMethod(JoinPoint jp) {
       ...
     }

     private static String logMethod(JoinPoint jp, Object result) {
       ...
     }
   }

The problem is that the Log field is an instance field, while it should be
a static one. But one cannot specify a static field inside an interface.

So my question is how to change the aspect implementation to make the Log a
static field?

Thanks.

--
Be well and prosper.
==============================
"There are two kinds of people.Those whose guns are loaded and those who
dig."
  ("The good, the bad and the ugly")
So let us drink for our guns always be loaded.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://dev.eclipse.org/mailman/private/aspectj-users/attachments/20111207/c844c749/attachment.htm>

------------------------------

Message: 2
Date: Wed, 7 Dec 2011 14:35:23 +0100
From: Eric Bodden <eric.bodden@xxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] AOSD 2012 Student Volunteer program
Message-ID:
       <CALhVNN+VG8Tc+kPrK00XmdSOcjr7ut2fY51zx=mq+8wHZnoYQg@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset=windows-1252

The Student Volunteer program is a great opportunity for students
interested in topics of advanced modularity and Aspect-Oriented
Software Development (AOSD) to stay tuned on the cutting edge
scientific and technical advances in this area. This is also an
opportunity for the interested grad and undergrad students to engage
with their peers: both students and senior researchers and
practitioners. As ever, the AOSD 2012 Student Volunteer program will
strive to provide an active and interactive environment for the
students to benefit from the research program of the conference, as
well as to develop their professional network and enjoy the social
events.

Special Call for Students From European Universities
* The AOSD 2012 Student Volunteer program will provide 10 dedicated
spots for graduate students from European universities
* The applications will be prioritized based on the relevance of the
student work to AOSD, the potential extension of the AOSD community
via integration of related work from new/underrepresented research
groups, and the circumstances of individual students.

The student volunteers will receive:
* Free student registration for the conference.
* Free participation in all social events including one banquet ticket.
* Excellent networking opportunities: both working as a team with
other volunteers, and interacting with other conference participants.
* The program chairs will strive to (as much as possible) ensure that
the volunteers are assigned to the tutorials, workshops,
demonstrations or other events of their interest.
* When not on duty, volunteers will have free admission to all
conference events, provided space is available.

The student volunteers will provide 15-20 hours of work on conference
support tasks throughout the duration of the conference, including:
* Technical assistance for the main conference sessions, workshops,
tutorials, demonstrations, or evening events.
* Help at conference bag packing and signposting.
* Help at the registration desk.
* Help in arranging, rearranging and disassembling conference ?facilities.
* Technical assistance to speakers and conference participants.

The applicants for student volunteer positions must be:
* Enrolled as a full-time student during the 2011-2012 academic year.
* Willing to be friendly (no natural outgoing personality required,
just a strong desire to do a good job).
* Proficient in English.
* Proficiency in other languages is an advantage.

How to Apply
Please send your application in English by email to the Student
Volunteers Chairs at [student-volunteers at aosd.net]. The Student
Volunteers Chairs will confirm receipt of the submission. An
application should include:
* A short motivation Letter;
* A CV
* Contact name, phone number, and email address of a faculty member at
your institution who will recommend you as a student volunteer
(Supervisors might be contacted to confirm the appropriateness of the
candidates.)
* The dates and times of your arrival and departure

In the event that one?s student volunteer application is not accepted,
you may still register using the early registration rate. Please
contact registration at aosd.net.
If you have further questions please contact the Student Volunteers
Chairs (Ruzanna Chitchyan or Jens Lincke) at volunteers at aosd.net.


------------------------------

Message: 3
Date: Wed, 7 Dec 2011 08:17:26 -0800
From: Andy Clement <andrew.clement@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] How to inject a static field into a
       multitude of types with AspectJ?
Message-ID:
       <CAAu=NOmTuzVFe0=JdoEWu5fHYih6=-yUXO3eCO5unSBM+JWz6w@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

Currently you can't make those static declarations on interfaces, but
it has been requested a few times and I would like to get to it soon.
In the meantime you can simulate it using a pertypewithin
instantiation model.  This thread discusses it:

http://aspectj.2085585.n4.nabble.com/Introduce-static-members-into-several-classes-at-once-td2080794.html

hope that helps,

cheers,
Andy

On 7 December 2011 01:44, mark Kharitonov <mark.kharitonov@xxxxxxxxx> wrote:
> I would like to add a log4j.Logger private static field into a multitude of
> types. For instance, into all the types annotated with the @Path annotation.
>
> This my current aspect code:
>
> ??? public aspect LoggingAspect {
> ????? public interface HttpHandlerType {}
> ????? declare parents: (@Path *) implements HttpHandlerType;
>
> ????? public Logger HttpHandlerType.Log = Logger.getLogger(getClass());
>
> ????? pointcut httpHandlerMethods(HttpHandlerType o) :
> within(HttpHandlerType+) &&
> ??????? execution(@(GET || PUT || POST || DELETE) public * *.*(..)) &&
> this(o);
>
> ????? before(HttpHandlerType o): httpHandlerMethods(o) {
> ??????? if (o.Log.isInfoEnabled()) {
> ????????? o.Log.info(logMethod(thisJoinPoint));
> ??????? }
> ????? }
>
> ????? after(HttpHandlerType o) returning (Object result):
> httpHandlerMethods(o) {
> ??????? if (o.Log.isDebugEnabled()) {
> ????????? o.Log.debug(logMethod(thisJoinPoint, result));
> ??????? }
> ????? }
>
> ????? after(HttpHandlerType o) throwing (Exception e): httpHandlerMethods(o)
> {
> ??????? if (o.Log.isEnabledFor(Level.ERROR)) {
> ????????? o.Log.error(logMethod(thisJoinPoint), e);
> ??????? }
> ????? }
>
> ????? private static String logMethod(JoinPoint jp) {
> ??????? ...
> ????? }
>
> ????? private static String logMethod(JoinPoint jp, Object result) {
> ??????? ...
> ????? }
> ??? }
>
> The problem is that the Log field is an instance field, while it should be a
> static one. But one cannot specify a static field inside an interface.
>
> So my question is how to change the aspect implementation to make the Log a
> static field?
>
> Thanks.
>
> --
> Be well and prosper.
> ==============================
> "There are two kinds of people.Those whose guns are loaded and those who
> dig."
> ?? ("The good, the bad and the ugly")
> So let us drink for our guns always be loaded.
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


------------------------------

Message: 4
Date: Wed, 7 Dec 2011 08:19:19 -0800
From: Andy Clement <andrew.clement@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Using aspect to pass a metadata as a
       parameter through SOAP
Message-ID:
       <CAAu=NO=SiBYbH=fB6yudM1U_HkzxJ9wJq5DMi9mxsES5Ynjhwg@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

> But I am wondering if this will even work and can be done using aspectj.
> It would be great if someone can tell me if this can be done using
> aspectj . If yes, will it solve my problem. Highly appreciate any
> help.

I guess in theory, what you are proposing will work.  But it may get
tricky to coordinate if there are multiple requests going on
simultaneously and multiple threads handling them.

cheers,
Andy

On 5 December 2011 10:50, Ashiwan.S. <sivakumarash007@xxxxxxxxx> wrote:
> Hi,
>
> Thank you so much for the reply.
> I guess I would have to modify the bytecode and xml specification for
> the data (since the application has been written to use SOAP). If
> that's the case, then I wonder if aspectj can help me at all in
> modularizing this work.
>
> I am thinking of doing something as below using aspectj.
>
> 1. Write a client side aspect which has a nested static class inside
> it. The class implements a remote method. The remote method will save
> the extra data in the object every time the data is available from the
> HTTP request.
> 2. Write a server side aspect such that , before the actual EJB call,
> make a remote method call to get the data and then proceed further
> with the actual call.,
>
> I understand that there is an extra overhead in making RMI call for
> every request received from the Front-end to the Business logic.
> But I am wondering if this will even work and can be done using aspectj.
> It would be great if someone can tell me if this can be done using
> aspectj . If yes, will it solve my problem. Highly appreciate any
> help.
>
> Thanks,
> Ashiwan
>
> --
> -Ashiwan
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


------------------------------

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


End of aspectj-users Digest, Vol 82, Issue 4
********************************************


Back to the top